package org.springframework.web.servlet.ajax.json;

import java.util.List;
import java.util.Map;

/**
 * Keeps track of commands a developer has given, presumably from a
 * Controller, in order to write a JSON object. JSON commands are stored, rather
 * than acted up immediately, because it's premature to write a JSON response in
 * the Controller. One issue is that Spring MVC has not yet stored the
 * appropriate Errors object in the Request, and this will prevent the
 * RequestContext from using PropertyEditors that have been registered on a
 * DataBinder. One way this problem manifests itself is that dates will not be
 * presented correctly in a form even though a CustomDateEditor has been
 * registered on the application's DataBinder.
 * 
 * @author Charles Tassoni
 */

//TODO  More documentation.
public interface JsonAjax {
	public static final String JAVASCRIPT_KEY = "javascript";
	public static final short AD_HOC_ADDITION = 1;
	public static final short JAVASCRIPT_VIA_VIEW = 2;
	public static final short JAVASCRIPT_VIA_STRING = 3;
	public static final short RENDER_A_PARTIAL = 4;

	public void addJavascript(String javascript);
	
	public void addJavascriptView(String viewName);
	
	public void addPartial(String jsonKey, String viewName);
	public void addPartial(String jsonKey, String viewName, Map modelOverride);
	
	public void addToJsonMap(Object key, Object value);
	
	/**
	 * Only call this if you know what you're doing!
	 * 
	 * @return contains all the information needed to
	 * create JSON based on the requests made of the
	 * JsonAjax implementation.
	 */
	public List<List> getAllJsonWork();


}